<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户管理</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href=/resources/css/amazeui.chosen.css"/>
    <link rel="stylesheet" href="/resources/css/app.css">
    <script src="/resources/js/jquery.min.js"></script>
    <script src="/resources/js/amazeui.chosen.min.js"></script>

</head>

<body data-type="widgets">
<script src="/resources/js/theme.js"></script>
<div class="am-g tpl-g">

    <%--头部开始--%>
    <%@include file="header.jsp" %>
    <%--头部结束--%>

    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <%-- 消息 --%>
                        <div class="container-fluid am-cf">
                            <div class="row">
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                                    <div class="page-header-heading"><span
                                            class="am-icon-smile-o page-header-heading-icon"></span> 流程管理
                                        <small>User information management</small>
                                    </div>
                                    <p class="page-header-description">对信息进行操作。</p>
                                </div>
                                <div class="am-u-lg-3 tpl-index-settings-button">
                                    <%--<button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>--%>
                                </div>
                            </div>
                        </div>
                        <%-- 表格 --%>
                        <div class="widget-body  am-fr">

                            <!-- 用户表开始 -->
                            <div class="am-u-sm-12 tableDiv">
                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black">
                                    <thead>
                                    <tr>

                                        <th class="am-text-center">病历编号</th>
                                        <th class="am-text-center">用户名</th>
                                        <th class="am-text-center">联系电话</th>
                                        <th class="am-text-center">时间</th>
                                        <th class="am-text-center">宝宝姓名</th>
                                        <th class="am-text-center">当前状态</th>
                                        <th class="am-text-center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody class="am-text-center">
                                    <!-- more data -->
                                    <c:forEach items="${pageInfo.list }" var="illCase">
                                        <tr>
                                            <td>${illCase.illCaseNo}</td>
                                            <td>${illCase.userName}</td>
                                            <td>${illCase.userTel}</td>
                                            <td>
                                                ${fn:substring(illCase.visitDate, 0, 10)}
                                            </td>
                                            <td>${illCase.babyName}</td>
                                            <td>
                                                <c:choose>
                                                    <c:when test="${illCase.illCaseState == 0}">等待采集数据</c:when>
                                                    <c:when test="${illCase.illCaseState == 1}">等待开单</c:when>
                                                    <c:when test="${illCase.illCaseState == 2}">开单完成</c:when>
                                                    <c:when test="${illCase.illCaseState == 3}">等待会诊</c:when>
                                                    <c:when test="${illCase.illCaseState == 4}">会诊完成</c:when>
                                                    <c:when test="${illCase.illCaseState == 5}">预约</c:when>
                                                    <c:when test="${illCase.illCaseState == 6}">已结算</c:when>
                                                </c:choose>
                                            </td>
                                                <%--<td>
                                                    ${fn:substring(b.infoInputDate, 0, 10)}
                                                </td>--%>
                                            <td>
                                                <c:if test="${illCase.illCaseState == 0}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success"  onclick="window.location.href='/process/second?id=${illCase.illCaseId}'">
                                                        <span class="am-icon-edit"></span> 采集数据
                                                    </button>
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" data-no="${illCase.illCaseNo}" data-url="/process/second?id=${illCase.illCaseId}"  onclick="getOnlineEmp(this,'information')">
                                                        <span class="am-icon-edit"></span> 员工采集
                                                    </button>
                                                </c:if>
                                                <c:if test="${illCase.illCaseState == 1}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="window.location.href='/process/third?id=${illCase.illCaseId}'">
                                                        <span class="am-icon-edit"></span> 进入开单
                                                    </button>
                                                </c:if>
                                              <%--  <c:if test="${illCase.illCaseState == 2}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="">
                                                        <span class="am-icon-edit"></span> 进入诊断
                                                    </button>
                                                </c:if>--%>
                                                <c:if test="${illCase.illCaseState == 3}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="window.location.href='/process/third?id=${illCase.illCaseId}'">
                                                        <span class="am-icon-edit"></span> 会诊完成
                                                    </button>
                                                </c:if>
                                                <c:if test="${illCase.illCaseState == 4}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="window.open('/process/printPrescription?ilid=${illCase.illCaseId}')">
                                                        <span class="am-icon-fax"></span> 查看打印处方
                                                    </button>

                                                    <c:choose>
                                                        <c:when test="${empty illCase.reserve11}">
                                                            <button type="button" class="am-btn am-btn-xs am-btn-success" data-no="${illCase.illCaseNo}" data-url="/process/printPrescription?ilid=${illCase.illCaseId}"  onclick="getOnlineEmp(this,'nurse')">
                                                                <span class="am-icon-hand-paper-o"></span> 调理师
                                                            </button>
                                                        </c:when>
                                                        <c:otherwise>
                                                            <button type="button" class="am-btn am-btn-xs am-btn-default">
                                                                <span class="am-icon-hand-paper-o"></span> 调理师
                                                            </button>
                                                        </c:otherwise>
                                                    </c:choose>

                                                    <c:choose>
                                                        <c:when test="${empty illCase.reserve12}">
                                                            <button type="button" class="am-btn am-btn-xs am-btn-success" data-no="${illCase.illCaseNo}" data-url="/process/printPrescription?ilid=${illCase.illCaseId}"  onclick="getOnlineEmp(this,'cooker')">
                                                                <span class="am-icon-coffee"></span> 食疗师
                                                            </button>
                                                        </c:when>
                                                        <c:otherwise>
                                                            <button type="button" class="am-btn am-btn-xs am-btn-default">
                                                                <span class="am-icon-coffee"></span> 食疗师
                                                            </button>
                                                        </c:otherwise>
                                                     </c:choose>



                                                    <c:if test="${fn:trim(sessionScope.typename) =='cashier' || fn:trim(sessionScope.typename) =='shopAdmin' || fn:trim(sessionScope.typename) =='admin'|| fn:trim(sessionScope.typename) =='shopadmin'}" >
                                                        <button type="button" id="btn${illCase.illCaseId}" class="am-btn am-btn-xs am-btn-danger" data-no="${illCase.illCaseNo}" data-url="/process/printPrescription?ilid=${illCase.illCaseId}"   onclick="sett(${illCase.illCaseId})">
                                                            <span class="am-icon-money"></span> 收钱结算
                                                        </button>

                                                    </c:if>
                                                    <c:if test="${fn:trim(sessionScope.typename) !='cashier'}">
                                                        <button type="button" class="am-btn am-btn-xs am-btn-success" data-no="${illCase.illCaseNo}" data-url="/illCaseController/getillcase?pn=1&status=4"  onclick="getOnlineEmp(this,'cashier')">
                                                            <span class="am-icon-money"></span> 收银员
                                                        </button>
                                                    </c:if>

                                                </c:if>
                                                <c:if test="${illCase.illCaseState != 4}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-secondary" onclick="checkPrescription('${illCase.illCaseId}')" data-am-modal="{target: '#formModel', width: 900}">
                                                        <span class="am-icon-eye"></span> 查看处方详情
                                                    </button>
                                                    <button type="button" class="am-btn am-btn-xs am-btn-secondary" onclick="checkVipInfo('${illCase.userId}')" data-am-modal="{target: '#formModel', width: 900}">
                                                        <span class="am-icon-eye"></span> 查看会员数据
                                                    </button>
                                                </c:if>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                            <!-- 用户表结束 -->

                            <!-- 分页开始 -->
                            <div class="am-u-lg-12 am-cf pageInfoTotal">

                                <!-- 分页文字信息，其中分页信息都封装在pageInfo中 -->
                                <div class="col-md-6 ">
                                    当前第：${pageInfo.pageNum }页，总共：${pageInfo.pages }页，总共：${pageInfo.total }条记录
                                </div>
                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <!-- 首页 -->
                                        <li><a href="/illCaseController/getillcase?pn=1&status=${status}">首页</a></li>
                                        <!-- 上一页 -->
                                        <c:if test="${pageInfo.hasPreviousPage }">
                                            <li>
                                                <a href="/illCaseController/getillcase?status=${status}&pn=${pageInfo.pageNum-1 }"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true">&laquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接 -->
                                        <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
                                            <c:if test="${page_Num == pageInfo.pageNum }">
                                                <li class="am-active"><a
                                                        href="/illCaseController/getillcase?status=${status}&pn=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                            <c:if test="${page_Num != pageInfo.pageNum }">
                                                <li>
                                                    <a href="/illCaseController/getillcase?status=${status}&pn=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                        </c:forEach>
                                        <!-- 下一页 -->
                                        <c:if test="${pageInfo.hasNextPage }">
                                            <li>
                                                <a href="/illCaseController/getillcase?status=${status}&pn=${pageInfo.pageNum+1 }"
                                                   aria-label="Next">
                                                    <span aria-hidden="true">&raquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 末页 -->
                                        <li><a href="/illCaseController/getillcase?status=${status}&pn=${pageInfo.pages }">末页</a></li>
                                    </ul>
                                </div>
                            </div>
                            <!-- 分页结束 -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


        <%--消息推送模态框start--%>
        <div class="am-modal am-modal-prompt" tabindex="-1" id="my-push-model">
            <div class="am-modal-dialog">
                <div class="am-modal-hd">请选择员工进行操作</div>
                <div class="am-modal-bd">
                    <select id="push-chosen" class="chosen-select" data-placeholder="请选择一个员工进行操作" style="width:350px;">
                        <option></option>
                        <option value="100000">这个是员工姓名</option>
                    </select>
                 <%--   <input type="text" class="am-modal-prompt-input">--%>
                </div>
                <div class="am-modal-footer">
                    <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                    <span class="am-modal-btn" data-am-modal-confirm>推送消息</span>
                </div>
            </div>
        </div>
        <%--消息推送模态框end--%>


    <!-- 查看会员信息模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="formModel">
        <div class="am-modal-dialog">
            <div class="am-modal-bd" style="padding: 2px;">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf" style="margin: 0;">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"><h2>会员信息查看</h2></div>
                                <div class="widget-function am-fr">
                                    <a href="javascript: void(0)" class="am-close am-close-spin clearForm"
                                       data-am-modal-close>&times;</a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">
                                <form class="am-form tpl-form-border-form tpl-form-border-br" id="addUserForm">

                                    <!-- 数据库主键(隐藏) -->
                                    <div class="am-form-group am-hide">
                                        <label class="am-u-sm-3 am-form-label">userId</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="id" class="am-form-field tpl-form-no-bg Id">
                                            <input type="text" name="userId"
                                                   class="am-form-field tpl-form-no-bg userId">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small>不可编辑！</small>
                                        </div>
                                    </div>

                                    <!-- 会员、学员 -->
                                    <%--  <div class="am-form-group">
                                          <label class="am-u-sm-3 am-form-label">用户身份</label>
                                          <div class="am-u-sm-6">
                                              <div class="am-form-group">
                                                  <label class="am-radio-inline">
                                                      <input class="reserve1" type="radio" name="reserve1" value="0"
                                                             checked="checked"> 会员
                                                  </label>
                                                  <label class="am-radio-inline">
                                                      <input class="reserve1" type="radio" name="reserve1" value="1"
                                                             onchange=""> 学员
                                                  </label>
                                              </div>
                                          </div>
                                          <div class="am-u-sm-3">
                                              <small style="color: green"></small>
                                          </div>
                                      </div>--%>

                                    <!-- 姓名 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">用户名</label>
                                        <div class="am-u-sm-6">
                                            <input maxlength="18" type="text" name="userName"
                                                   class="tpl-form-input userName" id="userInfoName"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>
                                    

                                    <!-- 宝宝姓名 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝姓名</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyName"
                                                   class="am-form-field tpl-form-no-bg BabyName" id="babyName"
                                                   placeholder="小宝贝" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝档案编号 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝档案编号</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="fileNo" id="babyfileNo"
                                                   class="am-form-field tpl-form-no-bg fileNo"
                                                   placeholder="123123123123" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝性别 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝性别</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babySex" id="babySex"
                                                   class="am-form-field tpl-form-no-bg babySex"
                                                   placeholder="男" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝年龄 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝年龄</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyAge"
                                                   class="am-form-field tpl-form-no-bg babyAge" id="babyAge"
                                                   placeholder="1" readonly>周岁
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝体重 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝体重</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyWeight"
                                                   class="am-form-field tpl-form-no-bg babyWeight" id="babyWeight"
                                                   placeholder="3000" readonly>kg
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝身高 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝身高</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyHeight"
                                                   class="am-form-field tpl-form-no-bg babyHeight" id="babyHeight"
                                                   placeholder="90" readonly>cm
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 会员编号 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">会员编号</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="vipNo" id="vipNo"
                                                   class="am-form-field tpl-form-no-bg vipNo"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 会员等级 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">会员等级</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="vipCategory"
                                                   class="am-form-field tpl-form-no-bg vipCategory" id="vipCategory"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 所属分店 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">所属分店</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="branname"
                                                   class="am-form-field tpl-form-no-bg branname" id="branname"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 余额 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">余额</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="balance"
                                                   class="am-form-field tpl-form-no-bg balance" id="vipbalance"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 剩余消费次数 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">剩余消费次数</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="remainTime" id="vipremainTime"
                                                   class="am-form-field tpl-form-no-bg remainTime"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 按钮 -->
                                    <div class="am-form-group">
                                        <div class="am-u-sm-12">
                                            <button type="button"
                                                    class="am-btn am-btn-primary tpl-btn-bg-color-success  clearForm"
                                                    data-am-modal-close=""><i class="am-icon-close"></i> 关闭
                                            </button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 整个表单结束 -->
            </div>
        </div>
    </div>
    <!-- 查看会员信息模态框结束 -->



        <!-- 查看处方明细模态框开始 -->
        <div class="am-modal am-modal-no-btn" tabindex="-1" id="presModal">
            <div class="am-modal-dialog">
                <div class="am-modal-bd" style="padding: 2px;">
                    <div class="row">
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                            <div class="widget am-cf" style="margin: 0;">
                                <div class="widget-head am-cf">
                                    <div class="widget-title am-fl"><h2>会员信息查看</h2></div>
                                    <div class="widget-function am-fr">
                                        <a href="javascript: void(0)" class="am-close am-close-spin clearForm"
                                           data-am-modal-close>&times;</a>
                                    </div>
                                </div>
                                <div class="widget-body am-fr">
                                    <!-- 用户表开始 -->
                                    <div class="am-u-sm-12 tableDiv">
                                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black">
                                            <thead>
                                            <tr>

                                                <th class="am-text-center">类型</th>
                                                <th class="am-text-center">商品\穴位名称与用量</th>
                                                <th class="am-text-center">单价</th>
                                            </tr>
                                            </thead>
                                            <tbody class="am-text-center">
                                                <tr>
                                                    <td>商品</td>
                                                    <td>大白菜 1 袋</td>
                                                    <td>20元</td>
                                                </tr>
                                                <tr>
                                                    <td>穴位</td>
                                                    <td>太阳穴 2 次</td>
                                                    <td>20元</td>
                                                </tr>
                                                <tr>
                                                    <td>总价</td>
                                                    <td><input type="text" value="40">元</td>
                                                </tr>
                                            <!-- more data -->
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- 用户表结束 -->
                                    <!-- 按钮 -->
                                    <div class="am-form-group">
                                        <div class="am-u-sm-12">
                                            <button type="button"
                                                    class="am-btn am-btn-primary tpl-btn-bg-color-success  clearForm"
                                                    data-am-modal-close=""><i class="am-icon-close"></i> 关闭
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 整个表单结束 -->
                </div>
            </div>
        </div>
        <!-- 查看处方明细模态框结束 -->

        <div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
            <div class="am-modal-dialog">
                <div class="am-modal-hd"></div>
                <div class="am-modal-bd" id="alertMsg">

                </div>
                <div class="am-modal-footer">
                    <span class="am-modal-btn" data-am-modal-confirm>确定</span>
                </div>
            </div>
        </div>

        <div class="am-modal am-modal-alert" tabindex="-1" id="remy-alert">
            <div class="am-modal-dialog">
                <div class="am-modal-hd">
                    <input type="hidden" id="reillcaseId">
                </div>
                <div class="am-modal-bd" id="realertMsg">

                </div>
                <div class="am-modal-footer">
                    <span class="am-modal-btn" id="recheck">确定</span>
                </div>
            </div>
        </div>






</div>

<script src="/resources/js/amazeui.min.js"></script>
<script src="/resources/js/amazeui.datatables.min.js"></script>
<script src="/resources/js/dataTables.responsive.min.js"></script>
<script src="/resources/js/app.js"></script>
<script src="/resources/jsutlis/fileutli.js"></script>
<script>

function checkPrescription(id){
    window.location.href = "/process/getHistory?id="+id;
}

function checkVipInfo(uid) {
    var formdata = new FormData();
    formdata.append("uid",uid);
    $.ajax({
        url: "/userInfoController/getallInfo",
        type: 'POST',
        cache: false,
        data: formdata,
        async: false,
        processData: false,
        contentType: false
    }).done(function (res) {
        console.log(res);
      var userInfo = res.userInfo;
      var vipInfo = res.vipInfo;
      var babyInfo = res.babyInfo;
      var vipcard = res.vipCard;
      var branches =res.branches;
        if (userInfo !=null && userInfo!=undefined && userInfo!=''){
              $('#userInfoName').val(userInfo.userName);
        }
        if (babyInfo !=null && babyInfo!=undefined && babyInfo!=''){
            $('#babyName').val(babyInfo.babyName);
            $('#babyfileNo').val(babyInfo.fileNo);
            var sex = babyInfo.babySex ==1?"男":"女";
            $('#babySex').val(sex);
            $('#babyAge').val(babyInfo.babyAge);
            $('#babyWeight').val(babyInfo.babyWeight);
            $('#babyHeight').val(babyInfo.babyHeight);

        }
        if (vipInfo !=null && vipInfo!=undefined && vipInfo!=''){
            $('#vipNo').val(vipInfo.vipNo);
            $('#vipbalance').val(vipInfo.balance);
            var times =vipInfo.remainTime;
            $('#vipremainTime').val(times);
        }
        if (vipcard !=null && vipcard!=undefined && vipcard!=''){
            $('#vipCategory').val(vipcard.vipName);
        }

        if (branches !=null && branches!=undefined && branches!=''){
            $('#branname').val(branches.branName);
        }
    });
}

function sett(illCaseId) {
    url ='/process/settlment?illid='+illCaseId;
    $.ajax({
        url: url,
        type: 'POST',
        cache: false,
        processData: false,
        contentType: false
    }).done(function (res) {
        console.log(res);
        if(res.success){
            $("#alertMsg").html("");
            $("#alertMsg").append("<p>"+res.msg+"</p>");
            $("#my-alert").modal({target: '#my-alert',
                onConfirm: function(options) {
                    window.location.reload();
                }
            });
            // window.location.reload();
        }else {
            if(res.data != undefined && res.data != null && res.data!= ''){
                if((res.data.enough != undefined && res.data.enough != null && res.data.enough != '')){
                    //显示库存不足的商品列表
                    $("#alertMsg").html("");
                    $("#alertMsg").append("<p>"+res.data.msg+"</p>");
                    var alertTable = "<table class=\"am-u-sm-12 am-u-lg-12 am-table am-table-bordered am-table-compact tpl-table-black\"\n" +
                        "                           id=\"alertDetail\">\n" +
                        "                        <tr>\n" +
                        "                            <td>\n" +
                        "                                名字\n" +
                        "                            </td>\n" +
                        "                            <td>单价</td>\n" +
                        "                            <td>\n" +
                        "                                类型\n" +
                        "                            </td>\n" +
                        "                        </tr>\n" +
                        "                    </table>";
                    $("#alertMsg").append(alertTable);
                    $("#typePromenu tr:not(:first)").html("");
                    for(var i = 0 ; i < res.data.enough.length ; i++){
                        var detailType = ""
                        switch (res.data.enough[i].pretype){
                            case "dietary" :
                                detailType = "商品";
                                break;
                        }
                        var alertTr = "<tr>\n" +
                            "                <td>\n" +
                            "                   "+res.data.enough[i].prename+"\n" +
                            "                </td>\n" +
                            "                <td>"+res.data.enough[i].preprice+"</td>\n" +
                            "                <td>\n" +
                            "                   "+ detailType+"\n" +
                            "                </td>\n" +
                            "            </tr>"
                        $("#alertDetail").append(alertTr);
                    }
                    $("#my-alert").modal({target: '#my-alert'});
                }
                if((res.data.noexist != undefined && res.data.noexist != null && res.data.noexist != '')){
                    //显示总店有，但是分店没有的商品列表
                    $("#alertMsg").html("");
                    $("#alertMsg").append("<p>"+res.data.msg1+"</p>");
                    var alertTable = "<table class=\"am-u-sm-12 am-u-lg-12 am-table am-table-bordered am-table-compact tpl-table-black\"\n" +
                        "                           id=\"alertDetail\">\n" +
                        "                        <tr>\n" +
                        "                            <td>\n" +
                        "                                名字\n" +
                        "                            </td>\n" +
                        "                            <td>单价</td>\n" +
                        "                            <td>\n" +
                        "                                类型\n" +
                        "                            </td>\n" +
                        "                        </tr>\n" +
                        "                    </table>"
                    $("#alertMsg").append(alertTable);
                    $("#typePromenu tr:not(:first)").html("");
                    for(var i = 0 ; i < res.data.noexist.length ; i++){
                        var detailType = ""
                        switch (res.data.noexist[i].pretype){
                            case "dietary" :
                                detailType = "商品";
                                break;
                        }
                        var alertTr = "<tr>\n" +
                            "                <td>\n" +
                            "                   "+res.data.noexist[i].prename+"\n" +
                            "                </td>\n" +
                            "                <td>"+res.data.noexist[i].preprice+"</td>\n" +
                            "                <td>\n" +
                            "                   "+ detailType+"\n" +
                            "                </td>\n" +
                            "            </tr>"
                        $("#alertDetail").append(alertTr);
                    }
                    $("#my-alert").modal({target: '#my-alert'});
                }
            }else {
                $("#alertMsg").html("");
                $("#alertMsg").append("<p>"+res.msg+"</p>");
                $("#my-alert").modal({target: '#my-alert'});
            }
            //添加重新开单按钮
                var but = '<button type="button" class="am-btn am-btn-xs am-btn-warning" style="margin-left:2px" data-no="${illCase.illCaseNo}" onclick="cancelPre('+illCaseId+')">'
                 +'<span class="am-icon-money"></span>重新开单'
                 +' </button>';
                var id ='#btn'+illCaseId;
                $(id).after(but);
        }
    }).fail(function (res) {
        console.log(res);
        alert("网络错误");

        //  return res;
    });
}

function cancelPre(illCaseId) {
    $('#reillcaseId').val("");
    $("#realertMsg").html("");
    $("#realertMsg").append("<p>该操作将会清空诊断结果等信息，重新进行诊断并开单,点击确定进行重新开单</p>");
    $('#reillcaseId').val(illCaseId);
    $("#remy-alert").modal({target: '#remy-alert'});

}

$('#recheck').bind("click",function () {
    var illCaseId = $('#reillcaseId').val();
    console.log("取消订单"+illCaseId);
    url ='/process/recheck';
    var formdata = new FormData();
    formdata.append("illid",illCaseId);
    $.ajax({
        url: url,
        type: 'POST',
        data: formdata,
        async: false,
        cache: false,
        processData: false,
        contentType: false
    }).done(function (res) {
        if (res.success) {
            window.location.reload();
        }else {
            alert("处理错误，请重新处理");
        }
    }).fail(function (res) {
        console.log(res);
        alert("网络错误");
    });
});

</script>
</body>

</html>